import sys
import httplib
import threading

thread_num = 1

if len(sys.argv) < 3:
  sys.exit('Usage: %s port number-of-hits' % sys.argv[0])

class MyThread(threading.Thread):
  def run(self):
    global thread_num
    conn = httplib.HTTPConnection("localhost:%s" % sys.argv[1])
    conn.request("GET", "")
    r1 = conn.getresponse()
    print('This is thread ' + str(thread_num))
    print(r1.status, r1.reason)
    data1 = r1.read()
    print(data1)
    conn.close()
    thread_num = thread_num + 1

for x in xrange (int(sys.argv[2])):
  MyThread().start()
